package cn.com.roy.thread.t3_1_12.pipeInputOutput;

import java.io.PipedInputStream;
import java.io.PipedOutputStream;

public class ReadData {
    public void readMethod(PipedInputStream inputStream) {
        try {
            System.out.println("read:");
            byte[] bytes = new byte[20];
            int readLength = inputStream.read(bytes);
            while (readLength != -1){
                String newData = new String(bytes,0,readLength);
                System.out.println(newData);
                readLength = inputStream.read(bytes);
            }
            System.out.println();
            inputStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
